<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
     <button id="btn">点击</button>
    <script type="text/javascript">
    // 练习:单击时触发单击事件， 双击时只触发双击事件
    //BOM:setTimeOut()
            btn.addEventListener('click',fn);
            btn.addEventListener('dblclick',fn1);
            var flag;
            
            function fn() {
                flag=false;
                var time=setTimeout(
                function () {
                if (flag=true) { 
                    alert('2班');
                    return ;
                }  
            },500) 
                 
    }
            function fn1() {
                flag=true;
                alert('4班');     
    }
        
    
        
            
        
</script>
</body>
</html>